Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
isset($_POST['value']) data is not recieved by php

I'm trying to send some values from a javascript file with POST to a php page.

AJAX code:

let inputval = $input.val();
$.ajax({url: "../checkout/test.php", type : 'post', data : {'inputval': inputval}, success: 
function(data){ 
                console.log(data);
              }

PHP code

 if (isset($_POST['inputval'])){
        $result = $_POST['inputval'];
        echo json_encode($result);
    }
    else {
        echo 'Not recieved';
    }

When I check it in networks all is as expected, but when I open the actual page the data is not recieved.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

when I open the actual page the data is not recieved.

First you make a POST request using JavaScript. The data is visible in the network tab. It it sent to the PHP program. The PHP program responds. The response is logged to the console.

Then you "open the actual page". This is a new request. It is not the POST request with the data. $_POST will be empty this time. The response will be the response to the new request, not the previous POST request. Since the content of the response depends on $_POST and that has changed, this response is different.

If you want to store the inputval data from the first request and then display it in subsequent requests you need to explicitly store it somewhere (such as a database or a session variable) and then check that location for data when you receive the subsequent request.

The logic would run something like:

IF this is a POST request
    store the inputval in the session
    send a confirmation message to the client
ELSE IF the session contains an inputval
    send it to the client
ELSE
    send a message to say that there is no data to the client
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda